//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.eResearch.Blackboard.Interfaces
{
    using System;

    /// <summary>
    /// Implementers of this interface provide code that allows the Blackboard to receive
    /// messages from a publisher.  The Blackboard will start and stop the receiver and
    /// subscribe to events that will be raised when a publisher registers/unregisters and
    /// when a new BlackboardMessage is received.
    /// </summary>
    public interface IPublisherMessageReceiver
    {
        /// <summary>
        /// Occurs when a new publisher registers with the Blackboard.
        /// </summary>
        event EventHandler<PublisherRegisteringEventArgs> PublisherRegistering;

        /// <summary>
        /// Occurs when a previously-registered publisher unregisters with the Blackboard.
        /// </summary>
        event EventHandler<PublisherUnregisteringEventArgs> PublisherUnregistering;

        /// <summary>
        /// Occurs when a new BlackboardMessage is received from a publisher.
        /// </summary>
        event EventHandler<BlackboardMessageReceivedEventArgs> BlackboardMessageReceived;

        /// <summary>
        /// Instructs the IPublisherMessageReceiver to begin listening for messages from publishers.
        /// </summary>
        void Start();

        /// <summary>
        /// Instructs the IPublisherMessageReceiver to stop listening for messages from publishers.
        /// </summary>
        void Stop();
    }
}
